package org.combat;

import org.rsbot.script.methods.MethodContext;
import org.rsbot.script.wrappers.RSTile;
import org.util.MethodGather;

/**
 * Created by IntelliJ IDEA.
 * User: Tim
 * Date: 9/8/11
 * Time: 5:02 PM
 * To change this template use File | Settings | File Templates.
 */
public class Fighter {
    MethodContext m;
    final RSTile wTile = new RSTile(3293, 3170);

    public Fighter(MethodGather methodGather) {
        m = methodGather.getMethodContext();
    }

    /**
     * Fights a warrior
     */
    public void fightWarrior() {
        if (m.players.getMyPlayer().isInCombat()) {
            m.env.sleep(m.env.random(400, 1250));
        } else if (m.players.getMyPlayer().isMoving()) {
            m.env.sleep(m.env.random(200, 550));
        } else {
            m.npcs.getNearest("Warrior").interact("Attack");
            m.env.sleep(m.env.random(400, 1250));
        }
    }

    /**
     * @return if we are at the warriors
     */
    public boolean atWarriors() {
        return m.calc.distanceTo(wTile) < 10;
    }
}
